﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of the data structure used to inspect beads.</summary>
	// Token: 0x0200001B RID: 27
	public class HBeadInspectionModel : HHandle
	{
		// Token: 0x0600019C RID: 412 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBeadInspectionModel() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x0600019D RID: 413 RVA: 0x00009668 File Offset: 0x00007868
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBeadInspectionModel(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600019E RID: 414 RVA: 0x00009677 File Offset: 0x00007877
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HBeadInspectionModel(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600019F RID: 415 RVA: 0x00009686 File Offset: 0x00007886
		private void AssertSemType()
		{
			base.AssertSemType("bead_inspection_model");
		}

		// Token: 0x060001A0 RID: 416 RVA: 0x00009693 File Offset: 0x00007893
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HBeadInspectionModel obj)
		{
			obj = new HBeadInspectionModel(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060001A1 RID: 417 RVA: 0x000096AC File Offset: 0x000078AC
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HBeadInspectionModel[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HBeadInspectionModel[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HBeadInspectionModel(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a model to inspect beads or adhesive in images.
		///   Modified instance represents: Handle for using and accessing the bead inspection  model.
		/// </summary>
		/// <param name="beadContour">XLD contour specifying the expected bead's shape and  position.</param>
		/// <param name="targetThickness">Optimal bead thickness. Default: 50</param>
		/// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to  TargetThickness. Default: 15</param>
		/// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param>
		/// <param name="polarity">The bead's polarity. Default: "light"</param>
		/// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		// Token: 0x060001A2 RID: 418 RVA: 0x0000971C File Offset: 0x0000791C
		public HBeadInspectionModel(HXLD beadContour, HTuple targetThickness, HTuple thicknessTolerance, HTuple positionTolerance, string polarity, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1985);
			HalconAPI.Store(proc, 1, beadContour);
			HalconAPI.Store(proc, 0, targetThickness);
			HalconAPI.Store(proc, 1, thicknessTolerance);
			HalconAPI.Store(proc, 2, positionTolerance);
			HalconAPI.StoreS(proc, 3, polarity);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(targetThickness);
			HalconAPI.UnpinTuple(thicknessTolerance);
			HalconAPI.UnpinTuple(positionTolerance);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(beadContour);
		}

		/// <summary>
		///   Create a model to inspect beads or adhesive in images.
		///   Modified instance represents: Handle for using and accessing the bead inspection  model.
		/// </summary>
		/// <param name="beadContour">XLD contour specifying the expected bead's shape and  position.</param>
		/// <param name="targetThickness">Optimal bead thickness. Default: 50</param>
		/// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to  TargetThickness. Default: 15</param>
		/// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param>
		/// <param name="polarity">The bead's polarity. Default: "light"</param>
		/// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		// Token: 0x060001A3 RID: 419 RVA: 0x000097C4 File Offset: 0x000079C4
		public HBeadInspectionModel(HXLD beadContour, int targetThickness, int thicknessTolerance, int positionTolerance, string polarity, string genParamName, int genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1985);
			HalconAPI.Store(proc, 1, beadContour);
			HalconAPI.StoreI(proc, 0, targetThickness);
			HalconAPI.StoreI(proc, 1, thicknessTolerance);
			HalconAPI.StoreI(proc, 2, positionTolerance);
			HalconAPI.StoreS(proc, 3, polarity);
			HalconAPI.StoreS(proc, 4, genParamName);
			HalconAPI.StoreI(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(beadContour);
		}

		/// <summary>
		///   Get the value of a parameter in a specific bead inspection model.
		///   Instance represents: Handle of the bead inspection model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter that is queried. Default: "target_thickness"</param>
		/// <returns>Value of the queried model parameter.</returns>
		// Token: 0x060001A4 RID: 420 RVA: 0x0000984C File Offset: 0x00007A4C
		public HTuple GetBeadInspectionParam(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1981);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get the value of a parameter in a specific bead inspection model.
		///   Instance represents: Handle of the bead inspection model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter that is queried. Default: "target_thickness"</param>
		/// <returns>Value of the queried model parameter.</returns>
		// Token: 0x060001A5 RID: 421 RVA: 0x000098A4 File Offset: 0x00007AA4
		public HTuple GetBeadInspectionParam(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1981);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set parameters of the bead inspection model.
		///   Instance represents: Handle of the bead inspection model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter that shall be adjusted for the specified bead inspection model. Default: "target_thickness"</param>
		/// <param name="genParamValue">Value of the model parameter that shall be adjusted for the specified bead inspection model. Default: 40</param>
		// Token: 0x060001A6 RID: 422 RVA: 0x000098F4 File Offset: 0x00007AF4
		public void SetBeadInspectionParam(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1982);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set parameters of the bead inspection model.
		///   Instance represents: Handle of the bead inspection model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter that shall be adjusted for the specified bead inspection model. Default: "target_thickness"</param>
		/// <param name="genParamValue">Value of the model parameter that shall be adjusted for the specified bead inspection model. Default: 40</param>
		// Token: 0x060001A7 RID: 423 RVA: 0x00009944 File Offset: 0x00007B44
		public void SetBeadInspectionParam(string genParamName, string genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1982);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Inspect beads in an image, as defined by the bead inspection model.
		///   Instance represents: Handle of the bead inspection model to be used.
		/// </summary>
		/// <param name="image">Image to apply bead inspection on.</param>
		/// <param name="rightContour">The detected right contour of the beads.</param>
		/// <param name="errorSegment">Detected error segments</param>
		/// <param name="errorType">Types of detected errors.</param>
		/// <returns>The detected left contour of the beads.</returns>
		// Token: 0x060001A8 RID: 424 RVA: 0x00009988 File Offset: 0x00007B88
		public HXLD ApplyBeadInspectionModel(HImage image, out HXLD rightContour, out HXLD errorSegment, out HTuple errorType)
		{
			IntPtr proc = HalconAPI.PreCall(1983);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HXLD result;
			num = HXLD.LoadNew(proc, 1, num, out result);
			num = HXLD.LoadNew(proc, 2, num, out rightContour);
			num = HXLD.LoadNew(proc, 3, num, out errorSegment);
			num = HTuple.LoadNew(proc, 0, num, out errorType);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
			return result;
		}

		/// <summary>
		///   Delete the bead inspection model and free the allocated memory.
		///   Instance represents: Handle of the bead inspection model.
		/// </summary>
		// Token: 0x060001A9 RID: 425 RVA: 0x00009A18 File Offset: 0x00007C18
		public void ClearBeadInspectionModel()
		{
			IntPtr proc = HalconAPI.PreCall(1984);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a model to inspect beads or adhesive in images.
		///   Modified instance represents: Handle for using and accessing the bead inspection  model.
		/// </summary>
		/// <param name="beadContour">XLD contour specifying the expected bead's shape and  position.</param>
		/// <param name="targetThickness">Optimal bead thickness. Default: 50</param>
		/// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to  TargetThickness. Default: 15</param>
		/// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param>
		/// <param name="polarity">The bead's polarity. Default: "light"</param>
		/// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		// Token: 0x060001AA RID: 426 RVA: 0x00009A4C File Offset: 0x00007C4C
		public void CreateBeadInspectionModel(HXLD beadContour, HTuple targetThickness, HTuple thicknessTolerance, HTuple positionTolerance, string polarity, HTuple genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1985);
			HalconAPI.Store(proc, 1, beadContour);
			HalconAPI.Store(proc, 0, targetThickness);
			HalconAPI.Store(proc, 1, thicknessTolerance);
			HalconAPI.Store(proc, 2, positionTolerance);
			HalconAPI.StoreS(proc, 3, polarity);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(targetThickness);
			HalconAPI.UnpinTuple(thicknessTolerance);
			HalconAPI.UnpinTuple(positionTolerance);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(beadContour);
		}

		/// <summary>
		///   Create a model to inspect beads or adhesive in images.
		///   Modified instance represents: Handle for using and accessing the bead inspection  model.
		/// </summary>
		/// <param name="beadContour">XLD contour specifying the expected bead's shape and  position.</param>
		/// <param name="targetThickness">Optimal bead thickness. Default: 50</param>
		/// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to  TargetThickness. Default: 15</param>
		/// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param>
		/// <param name="polarity">The bead's polarity. Default: "light"</param>
		/// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param>
		// Token: 0x060001AB RID: 427 RVA: 0x00009AF4 File Offset: 0x00007CF4
		public void CreateBeadInspectionModel(HXLD beadContour, int targetThickness, int thicknessTolerance, int positionTolerance, string polarity, string genParamName, int genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1985);
			HalconAPI.Store(proc, 1, beadContour);
			HalconAPI.StoreI(proc, 0, targetThickness);
			HalconAPI.StoreI(proc, 1, thicknessTolerance);
			HalconAPI.StoreI(proc, 2, positionTolerance);
			HalconAPI.StoreS(proc, 3, polarity);
			HalconAPI.StoreS(proc, 4, genParamName);
			HalconAPI.StoreI(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(beadContour);
		}
	}
}
